package leetCode;

/**
 * 冒泡
 */
public class BubbleSort {
    public static void main(String[] args) {
        int[] arr = {2, 5, 3, 7, 9, 12};
        for (int i = 1; i < arr.length; i++) {
            boolean flag = true;
            for (int j = 0; j < arr.length - i; j++) {
                if (arr[j] > arr[j + 1]) {
                    int temp = arr[j];
                    arr[j] = arr[j+1];
                    arr[j+1] = temp;
                    flag = false;
                }
            }
            if (flag) break;
        }
        for (int i : arr) {
            System.out.print(i);
        }
    }
}
